﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Transactions {
    import Engine.Transactions.*;
    import Engine.Managers.*;
    import Classes.*;
    import Classes.doobers.*;

    public class TBuyGoods extends Transaction {

        private var m_itemName:String;

        public function TBuyGoods(_arg1:String, _arg2:Boolean){
            var _local4:Boolean;
            super();
            this.m_itemName = _arg1;
            var _local3:Item = Global.gameSettings.getItemByName(this.m_itemName);
            if (_local3.cost > 0){
                Global.player.gold = (Global.player.gold - _local3.cost);
            } else {
                if (_local3.cash > 0){
                    Global.player.cash = (Global.player.cash - _local3.cash);
                } else {
                    GlobalEngine.msg((this.m_itemName + " cost nothing, make sure this is intentional behavior."));
                };
            };
            if (_arg2){
                _local4 = Global.player.inventory.removeItems(this.m_itemName, 1);
                if (!_local4){
                    ErrorManager.addError((("Item " + _local3.localizedName) + " not in inventory!"));
                };
            };
            Global.player.commodities.add(Doober.DOOBER_GOODS, _local3.goodsReward);
        }
        override public function perform():void{
            signedCall("UserService.buyGoods", this.m_itemName);
        }

    }
}//package Transactions 
